iT邦幫忙

2024 iThome 鐵人賽

DAY 7
0
DevOps

將 AI Code Review 整進 CICD系列 第 7

將 AI Code Review 整進 CICD Day7

  • 分享至 

  • xImage
  •  

將 AI Code Review 整進 CICD Day7

什麼是 GitLab CI Runner,我們在 CI 跑的動作是 CI Job,而跑這個 Job 的 worker 就是 runner。通常大公司內都會有多個多個 runner 供部署使用。如果 job 數量遠大於 runner,Job 就會處於 pending 的狀況。Runner 的運作模式是會不斷地向 Gitlab 發出 requests 確認有沒有需要執行的 runner。如果有 Job 且 Job 的 tag 跟 runner 符合,就可以執行。

如何安裝 runner

參考官方文檔,因為我只是自己的環境玩玩,我想採用最簡單的:Install GitLab Runner on macOS

  1. 下載 binary(Apple Silicon-based systems)

    sudo curl --output /usr/local/bin/gitlab-runner "https://s3.dualstack.us-east-1.amazonaws.com/gitlab-runner-downloads/latest/binaries/gitlab-runner-darwin-arm64"
    
  2. 給 permission 讓他可以執行

    sudo chmod +x /usr/local/bin/gitlab-runner
    
  3. 作為 runners 的 user

https://ithelp.ithome.com.tw/upload/images/20240821/2011852588soWMGY5M.png

https://ithelp.ithome.com.tw/upload/images/20240821/20118525bFe9u02glO.png

gitlab-runner register  --url https://gitlab.com  --token glrt-xxxxx
gitlab-runner register  --url https://gitlab.com  --token glrt-xxx
Runtime platform                                    arch=arm64 os=darwin pid=29503 revision=071ba93d version=17.3.0
WARNING: Running in user-mode.
WARNING: Use sudo for system-mode:
WARNING: $ sudo gitlab-runner...

Created missing unique system ID                    system_id=s_844cd5e23355
Enter the GitLab instance URL (for example, https://gitlab.com/):
[https://gitlab.com]:
Verifying runner... is valid                        runner=os1MWSbF6
Enter a name for the runner. This is stored only in the local config.toml file:
[Alvinlin.local]:
Enter an executor: custom, parallels, docker, docker-windows, docker+machine, kubernetes, instance, shell, ssh, virtualbox, docker-autoscaler:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

Configuration (with the authentication token) was saved in "/Users/alvinlin/.gitlab-runner/config.toml"

試著跑以下指令,會看到程序持續進行中

gitlab-runner run
$ gitlab-runner run       
Runtime platform                                    arch=arm64 os=darwin pid=29585 revision=071ba93d version=17.3.0
Starting multi-runner from /Users/alvinlin/.gitlab-runner/config.toml...  builds=0 max_builds=0
WARNING: Running in user-mode.
WARNING: Use sudo for system-mode:
WARNING: $ sudo gitlab-runner...

Configuration loaded                                builds=0 max_builds=1
listen_address not defined, metrics & debug endpoints disabled  builds=0 max_builds=1
[session_server].listen_address not defined, session endpoints disabled  builds=0 max_builds=1
Initializing executor providers                     builds=0 max_builds=1

https://ithelp.ithome.com.tw/upload/images/20240821/20118525lXxnbHSz7C.png

https://ithelp.ithome.com.tw/upload/images/20240821/20118525lBfKQvpDhG.png


上一篇
將 AI Code Review 整進 CICD Day6
下一篇
將 AI Code Review 整進 CICD Day8
系列文
將 AI Code Review 整進 CICD28
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言